package ArrayList;

import java.util.*;

public class TestTe {
    public static  void main(String[] args) {

        Map pen = new HashMap();
        pen.put("欧欧","Q仔");
        pen.put("亚亚","Q妹");
        pen.put("美美","Q妹");
        pen.put("菲菲","Q妹");

        //iterator 遍历
        Set key = pen.keySet();
        Iterator it=key.iterator();
        System.out.println("使用iterator来遍历");
        while(it.hasNext()){
            String keys=(String) it.next();
            String value=(String) pen.get(keys);
            System.out.println(keys+"\t"+ value);
        }

        //使用foreach 遍历
        System.out.println("使用foreach来遍历");
        for (Object key1:key){
            String penguin=(String) pen.get(key1);
            System.out.println(key1+"\t"+ penguin);
        }
    }
}
